package com.dycx.api.controller.manage.system;

import com.dycx.common.RestResponse;
import com.dycx.common.annotation.WriterLog;
import com.dycx.common.enums.BizTypeEnum;
import com.dycx.system.dto.RolePermissionDTO;
import com.dycx.system.service.RolePermissionService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping(value = "/manage/system/rolePermission")
public class RolePermissionController {

    @Resource
    private RolePermissionService rolePermissionService;

    /**
     * 添加
     **/
    @WriterLog(bizType = BizTypeEnum.SYS_ROLE, bizValue = "{#roleActionInsertDto.roleId}")
    @PostMapping("/insert")
    public RestResponse<?> insert(@RequestBody RolePermissionDTO roleActionInsertDto) {
        return rolePermissionService.insert(roleActionInsertDto) ? RestResponse.success() : RestResponse.fail();
    }

    /**
     * 查询 根据主键 id 查询
     **/
    @GetMapping("/getIdArr")
    public RestResponse<?> getIdArr(int roleId) {
        return RestResponse.success(rolePermissionService.getPermissionIds(roleId));
    }
}
